import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    num: 10,
    city: "武汉"
  },
  mutations: {
    add(state) {
      state.num++;
      console.log(state);
    },
    changeCity(state, val) {
      state.city = val
    }
  },
  actions: {
    addNum(ctx) {
      ctx.commit("add")
    },
    changeCity(ctx, val) {
      ctx.commit("changeCity", val)
    }
  },
  modules: {
  }
})
